import React, {useState, useEffect, createContext} from "react";
import {useNavigate} from 'react-router-dom';

export const GlobalContext = createContext({});

const AppProvider = ({children}) => {
    const [isLogin, setIsLogin] = useState(false);
    const navigate = useNavigate();

    // useEffect(() =>{
    //     if(isLogin) {
    //         navigate('/list')
    //     } else {
    //         navigate('/login')
    //     }
    // },[isLogin]);
   
    return <GlobalContext.Provider value={{isLogin, setIsLogin}}>
        {children}
    </GlobalContext.Provider>
}

export default AppProvider;